package com.ydj.framework.module.sms.service;

import com.ydj.framework.third.alisms.AliSmsManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 发送短信
 */
@Slf4j
@Service
public class SmsService {
    @Autowired
    private AliSmsManager smsManager;

    /**
     * 发送中奖短信
     */
    public void sendRaffle(String mobile, String prize) {
        try {
            log.info("发送短信【中奖短信】给" + mobile + "。");
            Map<String, Object> params = new HashMap<>();
            params.put("prize", prize);
            smsManager.sendSingle(AliSmsManager.SmsTemplateCode.中奖短信, mobile, params);
        } catch (Exception e) {
            log.error("发送短信【中奖短信】错误。", e);
        }
    }

}
